package com.atguigu.dao.impl;

import com.atguigu.dao.ProjectModuleTypeDao;
import com.atguigu.pojo.ProjectModuleType;

import java.util.List;

public class ProjectModuleTypeDaoImpl extends BaseDao implements ProjectModuleTypeDao {
    @Override
    public int addProjectModuleType(ProjectModuleType projectModuleType) {
        System.out.println("ProjectModuleTypeDaoImpl程序在[" + Thread.currentThread().getName() + "]线程中");
        String sql = "insert into t_projectModuleType(`id`,`name`) values(?,?);";
        return update(sql,projectModuleType.getId(),projectModuleType.getName());
    }
    @Override
    public int updateProjectModuleType(ProjectModuleType projectModuleType) {
        String sql = "update t_projectModuleType set `projectId`=?, `name`=?,`codeRepository`=? where id=?";
        return update(sql,projectModuleType.getName(), projectModuleType.getId());
    }

    @Override
    public int deleteProjectModuleTypeById(String id) {
        String sql = "delete from t_projectModuleType where id=?";
        return update(sql, id);
    }
    @Override
    public ProjectModuleType queryProjectModuleTypeByName(String name) {
        String sql = "select `id`,`name` from t_projectModuleType where name=?";
        return queryForOne(ProjectModuleType.class, sql, name);
    }

    @Override
    public ProjectModuleType queryProjectModuleTypeById(String id) {
        String sql = "select `id`,`name` from t_projectModuleType where id=?";
        return queryForOne(ProjectModuleType.class, sql, id);
    }

    @Override
    public List<ProjectModuleType> queryProjectModuleTypes() {
        String sql = "select `id`,`name` from t_projectModuleType";
        return queryForList(ProjectModuleType.class, sql);
    }

}
